/* show or hide an element */
function showHide(elementId) {
    var x = document.getElementById(elementId);
    if (x.style.display === "block") {
        x.style.display = "none";
    } else {
        x.style.display = "block";
    }
}

// (function (doc, win) {
//     var docEl = doc.documentElement,
//         resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
//         recalc = function () {
//             var clientWidth = docEl.clientWidth;
//             if (!clientWidth) return;
//             if(clientWidth>=750){
//                 docEl.style.fontSize = '16px';
//             }else{
//                 docEl.style.fontSize = 16 * (clientWidth / 750) + 'px';
//             }
//         };

//     if (!doc.addEventListener) return;
//     win.addEventListener(resizeEvt, recalc, false);
//     doc.addEventListener('DOMContentLoaded', recalc, false);
// })(document, window);
var countryStateInfo = {
    "USA": {
        "California": {
            "Los Angeles": ["90001", "90002", "90003", "90004"],
            "San Diego": ["92093", "92101"]
        },
        "Texas": {
            "Dallas": ["75201", "75202"],
            "Austin": ["73301", "73344"]
        }
    },
    "Australia": {
        "VIC": {
            "Melbourne": ["3010", "3055", "3056"],
            "Geelong": ["3219", "3221"],
            "Melton": ["3337", "3338"]
        },
        "NSW": {
            "Sydney": ["2055", "2059"],
            "Newcastle": ["2300", "2302"]
        }
    }
}

function fill_country() {
    //Get html elements
    var country_dl = document.getElementById("country_dl");
    //Load countries
    for (var country in countryStateInfo) {
        opt = document.createElement("OPTION");
        country_dl.options[country_dl.options.length] = new Option(country, country);
    }
}


//country Changed
function change_country() {
    var country_dl = document.getElementById("country_dl");
    var state_dl = document.getElementById("state_dl");
    var city_dl = document.getElementById("city_dl");
    var zip_dl = document.getElementById("zip_dl");

    // remove all options first
    state_dl.length = 1;
    city_dl.length = 1;
    zip_dl.length = 1;

    if (country_dl.selectedIndex < 1)
        return; // done

    // add the country data
    for (var state in countryStateInfo[country_dl.value]) {
        state_dl.options[state_dl.options.length] = new Option(state, state);
     }
}

//State Changed
function change_state() {
    var country_dl = document.getElementById("country_dl");
    var state_dl = document.getElementById("state_dl");
    var city_dl = document.getElementById("city_dl");
    var zip_dl = document.getElementById("zip_dl");

    // remove all options first
    city_dl.length = 1;
    zip_dl.length = 1;

    if (state_dl.selectedIndex < 1)
        return; // done

    // add the state data
    for (var city in countryStateInfo[country_dl.value][state_dl.value]) {
        city_dl.options[city_dl.options.length] = new Option(city, city);
    }
}